const mongoose = require('mongoose');
mongoose.Promise = global.Promise;
mongoose.set('useCreateIndex', true);

const connectAddress = process.env.NODE_ENV == 'development' ? 'mongodb://localhost/hotel' : 'mongodb://yao:yjr1923521@116.62.145.106/hotel';
mongoose.connect(connectAddress, {
    useNewUrlParser: true
})
const connection = mongoose.connection;
connection.once('open', () => {
    console.log('connect successful!')
})

module.exports = connection;
